$wh = []; $wh[] = "(1=1)"; if (!empty($params['q'])) $wh[] = "(keyword_name = '".escapeString($params['q'])."')"; if (!empty($params['pr_start'])) $wh[] = "(bg_cond_start_price >= ".intval($params['pr_start']).")"; if (!empty($params['pr_end'])) $wh[] = "(bg_cond_end_price <= ".intval($params['pr_start']).")"; $arr_q_in_txt = explode(" ", $params['q_in_txt']); $arr_q_ex_txt = explode(" ", $params['q_ex_txt']); $q_in_txt_condition = implode(" AND ", array_map(function($day) { return "JSON_CONTAINS(bg_cond_include_key, '\"$day\"')"; }, $arr_q_in_txt)); $q_ex_txt_condition = implode(" AND ", array_map(function($day) { return "JSON_CONTAINS(bg_cond_exclude_key, '\"$day\"')"; }, $arr_q_ex_txt)); if (!empty($params['q_in_txt'])) $wh[] = " ($q_in_txt_condition)"; if (!empty($params['q_ex_txt'])) $wh[] = " ($q_ex_txt_condition)"; $where = implode(" AND ", $wh); $sql = "SELECT * FROM ".self::$table_name." WHERE $where"; echo $sql;exit;
想對外分享這則貼文嗎?運用網址更方便呦~